home *** CD-ROM | disk | FTP | other *** search
/ Java Primer Plus / Java Primer Plus (Waite Group Proess)(1996).iso / java_Win / demo / ImageMap / HrefArea.class (.txt) < prev    next >
Encoding:
Java Class File  |  1995-10-12  |  1.5 KB  |  31 lines

  1. import java.awt.Graphics;
  2. import java.net.MalformedURLException;
  3. import java.net.URL;
  4.  
  5. class HrefArea extends ImageMapArea {
  6.    URL anchor;
  7.  
  8.    public void handleArg(String arg) {
  9.       try {
  10.          this.anchor = new URL(super.parent.getDocumentBase(), arg);
  11.       } catch (MalformedURLException var2) {
  12.          this.anchor = null;
  13.       }
  14.    }
  15.  
  16.    public void highlight(Graphics g, boolean on) {
  17.       super.highlight(g, on);
  18.       ((ImageMapArea)this).showStatus(on && this.anchor != null ? "Go To " + this.anchor.toExternalForm() : null);
  19.    }
  20.  
  21.    public void lift(int x, int y) {
  22.       if (((ImageMapArea)this).inside(x, y) && this.anchor != null) {
  23.          ((ImageMapArea)this).showDocument(this.anchor);
  24.       }
  25.  
  26.    }
  27.  
  28.    public HrefArea() {
  29.    }
  30. }
  31.